package com.yn.service.zy.model.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.yn.common.constants.Constants;
import com.yn.common.enums.AuditStatusEnum;
import com.yn.common.enums.CarStatusEnum;
import com.yn.common.model.zy.TCarManageDO;
import com.yn.common.utils.BeanUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.ObjectUtils;

import java.util.Date;

/**
 * @ClassName: TCarManageDTO
 * @Description:
 * @Author: lxp
 * @Date: 2025/5/9 10:35
 **/
@Data
@ApiModel("车辆-司机出参")
public class TCarManageDTO {
    @ApiModelProperty("车辆-司机主键id")
    private Integer id;

    @ApiModelProperty("车队id")
    private Integer fleetManageId;

    @ApiModelProperty("车队名称")
    private String fleetManageName;

    @ApiModelProperty("车牌号")
    private String carNumber;

    @ApiModelProperty("行驶证")
    private String drivingLicense;

    @ApiModelProperty("驾驶证")
    private String driverLicense;

    @ApiModelProperty("保险证明")
    private String insuranceCertificate;

    @ApiModelProperty("车辆联系电话")
    private String carLinkNumber;

    @ApiModelProperty("车长姓名")
    private String conductorName;

    @ApiModelProperty("车长身份证号")
    private String conductorIdNumber;

    @ApiModelProperty("审核状态 (0:审核中 1:审核通过 3:审核不通过)")
    private Integer auditStatus;

    @ApiModelProperty("审核状态字符")
    private String auditStatusStr;

    @ApiModelProperty("区域编码")
    private String regionCode;

    @ApiModelProperty("车辆状态(0:空闲 1:运营中 2:停运)")
    private Integer carStatus;

    @ApiModelProperty("车辆状态字符")
    private String carStatusStr;

    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = Constants.DATE_FORMAT)
    private Date createTime;

    public static TCarManageDTO transform(TCarManageDO tCarManageDO){
        if (ObjectUtils.isEmpty(tCarManageDO)) {
            return null;
        }

        TCarManageDTO tCarManageDTO = BeanUtils.copyProperties(tCarManageDO, TCarManageDTO.class);

        if (!ObjectUtils.isEmpty(tCarManageDTO.getCarStatus())) {
            CarStatusEnum carStatusEnum = CarStatusEnum.getByCode(tCarManageDTO.getCarStatus());
            if (!ObjectUtils.isEmpty(carStatusEnum)) {
                tCarManageDTO.setCarStatusStr(carStatusEnum.getName());
            }
        }

        if (!ObjectUtils.isEmpty(tCarManageDTO.getAuditStatus())) {
            AuditStatusEnum auditStatusEnum = AuditStatusEnum.getByCode(tCarManageDTO.getAuditStatus());
            if (!ObjectUtils.isEmpty(auditStatusEnum)) {
                tCarManageDTO.setAuditStatusStr(auditStatusEnum.getName());
            }
        }

        return tCarManageDTO;
    }
}
